import java.awt.*;


//stellt die TCPVerbindung her
public class Connector implements Runnable{
	public boolean server;
	public String ipAdd;
	public Main main;
	
	public Connector(boolean s, String ia, Main m){
		server = s;
		ipAdd = ia;
		main = m;
	}
	
	public void run(){
		if(server) showServerGui();
		else showClientGui();
		main.setSize(new Dimension(600,600));
		main.doLayout();
		
		connect();
		
		if(main.conn.mySocket==null || !main.conn.mySocket.isConnected()) connect();
		main.add(new Label("Verbindung hergestellt..."));
		main.doLayout();
		System.out.println(main.conn.mySocket.toString());
		main.startMenu();
	}
	
	public void connect(){
		main.conn = new TCPConnection(server,ipAdd,main.port);
	}
	
	
	public void showServerGui(){
		main.add(new Label("Verbindung mit Client wird hergestellt....."));
		main.add(new Label(ipAdd + " Port: " + main.port));
	}
	
	public void showClientGui(){
		main.add(new Label("Verbindung mit Server wird hergestellt....."));
		main.add(new Label(ipAdd + " Port: " + main.port));
	}
	
	
}
